<template>
  <div id="app">
      <div class="item" v-for="item of movies" :key="item.id" @click="handleClick(item._id)">
          <img :src="item.pic" alt="">
          <p>{{item.title}}</p>
      </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            movies:[]
        }
    },
    mounted(){
        axios.get("http://47.108.197.28:4000/api/movie/top250").then(res=>{
            // console.log(res.data.res);
            this.movies = res.data.res;
        })
    },
    methods:{
        handleClick(_id){
            console.log(_id);
            var id = _id
            this.$router.push(`/movieDetail/${id}`)
        }
    }
}
</script>

<style scoped>
    #app{
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .item{
        width: 150px;
        
    }
    img{
        width: 150px;
    }
</style>